package com.woniuxy.orderservice.rabbit.queue;

import com.woniuxy.core.model.Result;
import com.woniuxy.orderclient.client.ProcessFeignClient;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * 进度服务消息队列
 */
@Component
public class ProcessQueue {
    @Autowired
    private ProcessFeignClient pfc;

    /**
     * 生成私教订单进度队列
     * @param orderNum
     */
    @RabbitHandler
    @RabbitListener(queuesToDeclare = {@Queue(value ="coach-order-process-queue")})
    public void coachOrderProcessQueue(String orderNum) {
        Result res = pfc.addPricardProcess(orderNum);//进度服务模块处理
//        if (!res.getFlag()) throw new OrderException(res.getCode(),res.getMsg());
    }
    /**
     * 生成团课订单进度队列
     * @param orderNum
     */
    @RabbitHandler
    @RabbitListener(queuesToDeclare = {@Queue(value ="team-order-process-queue")})
    public void teamOrderProcessQueue(String orderNum) {
        Result res = pfc.addTeacardProcess(orderNum);//进度服务模块处理
//        if (!res.getFlag()) throw new OrderException(res.getCode(),res.getMsg());
    }
    /**
     * 生成次卡订单进度队列
     * @param orderNum
     */
    @RabbitHandler
    @RabbitListener(queuesToDeclare = {@Queue(value ="count-card-order-process-queue")})
    public void countCardOrderProcessQueue(String orderNum) {
        Result res = pfc.addCountCardProcess(orderNum);//进度服务模块处理
//        if (!res.getFlag()) throw new OrderException(res.getCode(),res.getMsg());
    }

    /**
     * 生成有效期卡订单进度队列
     * @param orderNum
     */
    @RabbitHandler
    @RabbitListener(queuesToDeclare = {@Queue(value ="valid-card-order-process-queue")})
    public void validCardOrderProcessQueue(String orderNum) {
        Result res = pfc.addValidCardProcess(orderNum);//进度服务模块处理
//        if (!res.getFlag()) throw new OrderException(res.getCode(),res.getMsg());
    }
}
